﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace KuWoMusic最终版
{
    class LyricFiles
    {
        //歌词文件
        public List<Lyric> lstLyric = new List<Lyric>();
        public void LoadLyric(string fileName)
        {
            Encoding encode = Encoding.GetEncoding("GB2312");
            FileStream fs = new FileStream(fileName, FileMode.Open);//打开歌词文件
            StreamReader sr = new StreamReader(fs, encode);//读取歌词文件
            string line;
            //依次循环读出所有歌词
            while ((line = sr.ReadLine()) != null)
            {
                if (line.Length > 10)//歌词不为空
                {
                    Lyric lyric = new Lyric();
                    lyric.minute = int.Parse(line.Substring(1, 2));
                    lyric.second = float.Parse(line.Substring(4, 5));
                    lyric.strLyric = line.Substring(10);
                    lyric.totSecond = lyric.minute * 60 + lyric.second;
                    lstLyric.Add(lyric);
                }
            }
            fs.Close();
        }
    }
    //一行歌词
    class Lyric
    {
        public int minute;      //分
        public float second;    //秒
        public float totSecond;  //转化为秒
        public string strLyric; //歌词
    }
}
